<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">卡权益状态</ui:define>
    <ui:define name="content">
        <h:form>
            <p:dialog id="addPrivilegeStatus" rendered="#{galaxyCardPrivilegeStatusBean.addingStatus != null}"
                      header="卡权益添加" position="center" widgetVar="addPrivilegeStatus" modal="true" width="85%"
                      height="90%" responsive="true" footer="行为内容中可通过包括如下字符串($...)达到动态替换相应参数的目的：[$cardInfoId:用户卡id,$orderId:订单id,$businessId:业务id,$userId:用户id,$cardNo:用户卡号,$phoneNumber:用户手机号,$privilegeInfoId:用户卡权益id,$token:用户ACCESS_TOKEN]">
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="addPrivilegeStatusPrivilege" value="权益名称"/>
                    <p:selectOneMenu id="addPrivilegeStatusPrivilege" value="#{galaxyCardPrivilegeStatusBean.addingStatus.privilegeId}">
                        <f:selectItems value="#{galaxyCardPrivilegeStatusBean.privilegeList}"/>
                    </p:selectOneMenu>
                    <p:outputLabel for="addPrivilegeStatusAction" value="权益行为"/>
                    <p:selectOneMenu id="addPrivilegeStatusAction" value="#{galaxyCardPrivilegeStatusBean.addingStatus.action}">
                        <f:selectItems value="#{galaxyCardPrivilegeStatusBean.actionList}"/>
                    </p:selectOneMenu>
                    <p:outputLabel for="addPrivilegeStatusName" value="状态显示"/>
                    <p:inputText id="addPrivilegeStatusName" value="#{galaxyCardPrivilegeStatusBean.addingStatus.show}" style="width:100%"/>
                    <p:outputLabel for="addPrivilegeStatusStatus" value="状态编码"/>
                    <p:inputText id="addPrivilegeStatusStatus" value="#{galaxyCardPrivilegeStatusBean.addingStatus.status}" style="width:100%"/>
                    <p:outputLabel for="addPrivilegeStatusTarget" value="行为内容"/>
                    <p:inputText id="addPrivilegeStatusTarget" value="#{galaxyCardPrivilegeStatusBean.addingStatus.target}" style="width:100%"/>
                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确定添加" actionListener="#{galaxyCardPrivilegeStatusBean.onAddPrivilegeStatus()}" process="addPrivilegeStatus" update="@form" />
                </div>
            </p:dialog>

            <p:dialog id="editPrivilegeStatus" rendered="#{galaxyCardPrivilegeStatusBean.selectedStatus != null}"
                      header="卡权益状态编辑" position="center" widgetVar="editPrivilegeStatus" modal="true" width="85%"
                      height="90%" responsive="true" footer="行为内容中可通过包括如下字符串($...)达到动态替换相应参数的目的：[$cardInfoId:用户卡id,$orderId:订单id,$businessId:业务id,$userId:用户id,$cardNo:用户卡号,$phoneNumber:用户手机号,$privilegeInfoId:用户卡权益id,$token:用户ACCESS_TOKEN]">
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="editPrivilegeStatusPrivilege" value="权益名称"/>
                    <p:selectOneMenu id="editPrivilegeStatusPrivilege" value="#{galaxyCardPrivilegeStatusBean.selectedStatus.privilegeId}" disabled="true">
                        <f:selectItems value="#{galaxyCardPrivilegeStatusBean.privilegeList}"/>
                    </p:selectOneMenu>
                    <p:outputLabel for="editPrivilegeStatusAction" value="权益行为"/>
                    <p:selectOneMenu id="editPrivilegeStatusAction" value="#{galaxyCardPrivilegeStatusBean.selectedStatus.action}">
                        <f:selectItems value="#{galaxyCardPrivilegeStatusBean.actionList}"/>
                    </p:selectOneMenu>
                    <p:outputLabel for="editPrivilegeStatusName" value="状态显示"/>
                    <p:inputText id="editPrivilegeStatusName" value="#{galaxyCardPrivilegeStatusBean.selectedStatus.show}" style="width:100%"/>
                    <p:outputLabel for="editPrivilegeStatusStatus" value="状态编码"/>
                    <p:inputText id="editPrivilegeStatusStatus" value="#{galaxyCardPrivilegeStatusBean.selectedStatus.status}" style="width:100%"/>
                    <p:outputLabel for="editPrivilegeStatusTarget" value="行为内容"/>
                    <p:inputText id="editPrivilegeStatusTarget" value="#{galaxyCardPrivilegeStatusBean.selectedStatus.target}" style="width:100%"/>
                    <p:outputLabel for="editPrivilegeStatusCreateTime" value="创建时间"/>
                    <p:inputText id="editPrivilegeStatusCreateTime" value="#{galaxyCardPrivilegeStatusBean.selectedStatus.createTime}"  disabled="true" style="width:100%"/>
                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确定编辑" actionListener="#{galaxyCardPrivilegeStatusBean.onEditPrivilegeStatus()}"
                                     rendered="#{security:areAllGranted('GALAXY_CARD_PRIVILEGE_STATUS_EDIT')}"
                                     process="editPrivilegeStatus" update="@form" />
                </div>
            </p:dialog>

            <p:confirmDialog message="贸然删除权益状态可能会导致黑卡系统出现问题，删除前先应询问开发人员!"
                             header="删除警告" severity="alert"
                             widgetVar="deletePrivilegeStatus">
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确认删除" actionListener="#{galaxyCardPrivilegeStatusBean.onDelete()}"
                                     update="@form" oncomplete="PF('deletePrivilegeStatus').hide()" />
                    <p:commandButton value="取消删除" onclick="PF('deletePrivilegeStatus').hide();" type="button" />
                </div>
            </p:confirmDialog>

            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="galaxyCardPrivilegeStatusDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         rendered="#{galaxyCardPrivilegeStatusBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{galaxyCardPrivilegeStatusBean.isNormal()}"
                                         actionListener="#{galaxyCardPrivilegeStatusBean.onReset}"
                                         process="@this" update="@form"/>
                        <p:commandButton icon="fa fa-plus" value="新增权益状态"
                                         rendered="#{security:areAllGranted('GALAXY_CARD_PRIVILEGE_STATUS_ADD')}"
                                         oncomplete="PF('addPrivilegeStatus').show()"/>
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}" rendered="#{galaxyCardPrivilegeStatusBean.isRedirectAt}"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="2" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="privilegeId" value="卡权益"/>
                                <p:selectOneMenu id="privilegeId" value="#{galaxyCardPrivilegeStatusBean.$.privilegeId}" filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="请选择" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems value="#{galaxyCardPrivilegeStatusBean.privilegeList}"/>
                                </p:selectOneMenu>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="galaxyCardPrivilegeStatusDataTable"
                                         style="width: 100%;text-align:center"
                                         var="status"
                                         value="#{galaxyCardPrivilegeStatusBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{galaxyCardPrivilegeStatusBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" style="width:70px;" rendered="#{security:areAllGranted('GALAXY_CARD_PRIVILEGE_STATUS_OPERATE')}">
                                    <p:splitButton icon="fa fa-pencil"
                                                   actionListener="#{galaxyCardPrivilegeStatusBean.onSelect(status)}"
                                                   oncomplete="PF('editPrivilegeStatus').show()"
                                                   process="@this" update="@form">
                                        <p:menuitem value="删除" icon="fa fa-arrow-up"
                                                    rendered="#{security:areAllGranted('GALAXY_CARD_PRIVILEGE_STATUS_DELETE')}"
                                                    actionListener="#{galaxyCardPrivilegeStatusBean.onSelect(status)}"
                                                    oncomplete="PF('deletePrivilegeStatus').show()"
                                                    process="@this" update="@form"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column headerText="ID" style="text-align:center;width:60px;">
                                    <h:outputText value="#{status.pk}"/>
                                </p:column>
                                <p:column headerText="权益名称">
                                    <h:outputText value="#{status.privilegeName}"/>
                                </p:column>
                                <p:column headerText="显示状态" style="text-align:center;">
                                    <h:outputText value="#{status.show}"/>
                                </p:column>

                                <p:column headerText="状态编码" style="text-align:center;width:60px;">
                                    <h:outputText value="#{status.status}"/>
                                </p:column>
                                <p:column headerText="下发行为" style="text-align:center;">
                                    <h:outputText value="#{status.actionString}"/>
                                </p:column>
                                <p:column headerText="下发内容" style="text-align:left;width:600px;">
                                    <h:outputText value="#{status.target}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>